import request from '@u/request'

// 请求首页banner
const getHomeBanner = (params ={} ) => {
  return request.get('/banner/list', {params})
}
// 请求分类列表
const getCates =  (params ={} ) => {
  return request.get('/shop/goods/category/all', {params})
}
// 请求商品列表
const getItems = (params ={} ) => {
  return request.post('/shop/goods/list/v2', params)
}
// 获取商品详情
const fetchItemDetail = (params ={} ) => {
  return request.get('/shop/goods/detail', {params})
}
// 用户注册
const regUser = (params ={} ) => {
  return request.post('/user/username/register', params)
}
// 用户登录
const regLogin = (params ={} ) => {
  return request.post('/user/username/login', params)
}
// 购物车接口
// 加入购物车
const addCart = (params = {}) => (
  request.post('/shopping-cart/add', params)
)
// 读取购物车数据
const fetchCartInfo = (params = {}) => (
  request.get('/shopping-cart/info', {params})
)
// 修改购物车商品购买数量
const modifyItemNum = (params = {}) => (
  request.post('/shopping-cart/modifyNumber', params)
)
// 删除购物车中的商品
const removeCartItem = (params = {}) => (
  request.post('/shopping-cart/remove', params)
)
// 修改购物车商品选中状态
const changeCartItemSelect = (params = {}) => (
  request.post('/shopping-cart/select', params)
)

export {
  getHomeBanner,
  getCates,
  getItems,
  fetchItemDetail,
  regUser,
  regLogin,
  addCart,
  fetchCartInfo,
  modifyItemNum,
  removeCartItem,
  changeCartItemSelect
}